
const request = window.axios
// 获取商品分类数据
export function getGoodsCateList (params) {
  return request({
    url: 'categories',
    method: 'get',
    params
  })
}

// 根据 id 查询分类
export function getGoodsCateById (id) {
  return request({
    url: 'categories/' + id
  })
}

// 修改商品分类
export function submitGoodsCate (id, data) {
  return request({
    url: 'categories/' + id,
    method: 'put',
    data
  })
}

// 删除商品分类
export function delGoodsCate (id) {
  return request({
    url: 'categories/' + id,
    method: 'delete'
  })
}

// 添加商品分类数据
export function postGoodsCate (data) {
  return request({
    url: 'categories',
    method: 'post',
    data
  })
}

// 获取动态或静态参数列表
export function getParamsList (id, sel) {
  return request({
    url: `categories/${id}/attributes`,
    method: 'get',
    params: { sel }
  })
}

// 添加动态或静态参数
export function postParams (id, data) {
  return request({
    url: `categories/${id}/attributes`,
    method: 'post',
    data
  })
}

// 查询参数
export function getParamsById (id, attrId, sel) {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'get',
    params: { attr_sel: sel }
  })
}

// 编辑提交参数
export function postEditParams (id, attrId, data) {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'put',
    data
  })
}

// 删除参数
export function delParams (id, attrId) {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'delete'
  })
}

// 获取商品列表
export function getGoodsList (params) {
  return request({
    url: 'goods',
    params
  })
}

// 删除商品
export function delGoods (id) {
  return request({
    url: 'goods/' + id,
    method: 'delete'
  })
}

// 根据Id查询商品
export function editGoodsById (id) {
  return request({
    url: 'goods/' + id
  })
}

// 添加商品
export function postShop (data) {
  return request({
    url: 'goods',
    method: 'post',
    data
  })
}
